/*
 *	Class that stores information about a bullet
 */

#ifndef __BULLET_H__
#define __BULLET_H__

#include <NxOgre.h>
#include <Ogre.h>
#include "Player.h"

class Bullet
{
public:
	Ogre::String bulletName;
	static int bulletID;
	Player* bulletFirer;
	
	NxOgre::Body* bulletBody;
	Ogre::SceneNode* bulletSceneNode;
	Ogre::Entity* bulletEntity;

	Ogre::Vector3 dir;
	Ogre::Vector3 startPos;
	Ogre::Vector3 rayStartPos;
	Ogre::Real range;
	Ogre::Real lifeTime;

	Ogre::String collisionObj;
	bool _hasCollided;
	bool _collidePlayer;
	bool _collideTerrain;
	
	//---//
	
	Bullet(NxOgre::Scene* nxScene, Player* player);
	~Bullet() {};

	Ogre::Vector3 getPosition(void) { return bulletBody->getGlobalPosition(); }
	Ogre::Quaternion getOrientation(void) { return bulletBody->getGlobalOrientation(); }
	Player* getFirer(void) { return bulletFirer; }
	int getBulletID(void) { return bulletID; }
	Ogre::String getName(void) { return bulletName; }
	Ogre::SceneNode* getSceneNode(void) { return bulletSceneNode; }
	Ogre::Entity* getEntity(void) { return bulletEntity; }
	NxOgre::Body* getBody(void) { return bulletBody; }

	void setPosition(Ogre::Vector3 newPos) { bulletBody->setGlobalPosition(newPos); }
	void setOrientation(Ogre::Quaternion newOrient) { bulletBody->setGlobalOrientation(newOrient); }

	bool updateBullet(NxOgre::Scene* nxScene, Player* p1, Player* p2, const FrameEvent& evt);
	bool collideWithTerrain() { return _collideTerrain; }
	bool collideWithPlayer() { return _collidePlayer; }
	bool hasCollided() { return _hasCollided; }
};
  
#endif